<?php
/**
 * @name ss_GetRelatedSongsLastFM.php
 * @abstract class to fetch Related Songs to a search query passed as param Last FM api
 * @param $NameArtist
 * @param $NameSong
 * 
 */
class ss_GetRelatedSongsLastFM {

  function ss_GetRelatedSongsLastFM ($NameArtist , $NameSong){
     
      
     $args = func_get_args();
     
     if ($args[0] !== null && $args[1] !== null) { 
     	
     	$NameArtist = urlencode($args[0]);
      $NameSong = urlencode($args[1]);
      
       
      //var_dump($searchString);
      //die();    
     
     $apikey = '10d3a093c88b89efa8b0cc2af8773469';
     
     $url = 'http://ws.audioscrobbler.com/2.0/?method=track.getsimilar&artist='.$NameArtist.'&track='.$NameSong.'&api_key='.$apikey;
           
     $doc = new DOMDocument();
     $doc->load($url);
          
     $entries = $doc->getElementsByTagName( "track" ); 
           
        foreach ( $tracks as $track ) { 
        
          $artist = $track->getElementsByTagName( "artist" );
          
          $counter = 0;
          while ($thumb->item($counter) !== null) {
          	
            $thumbValue = $thumb->item($counter)->getAttributeNode("url")->value;
          	$counter = $counter+1;
            
            //var_dump($thumbValue);
          	
          	 //if ( strpos($thumbValue, '70x53')!==false) {
          	 if ( strpos($thumbValue, '140x105')!==false) {
          	    $out = '<div class="thumbmtv" alt="'.$searchString.'"><img border="0" src="'.$thumbValue.'" /></div>';
                return  $out;
              }
          	
          	
          	
          
          	
          	
          	
          }
          
        	 
        	     
            
        	
        }
                            
      }

   }
    
}